<template>
    <div class="mainpage">
        <el-container>
            <el-aside width="20%">
                <navmenu :currentpage="'1'" />
            </el-aside>
            <el-container>
                <el-header>
                    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" active-text-color="#1477fe" text-color="#b9b9b9">
                    <el-menu-item index="1" @click="changeto1">待处理</el-menu-item>
                    <el-menu-item index="2" @click="changeto2">进行中</el-menu-item>
                    <el-menu-item index="3" @click="changeto3">已完成</el-menu-item>
                    </el-menu>
                </el-header>
                <el-main>
                    <div v-if="activeIndex=='1'">
                        <el-table
                        :data="patientlist1"
                        style="width: 60%">
                        <el-table-column
                            prop="consultId"
                            label="诊断id"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personName"
                            label="患者姓名"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personPhoneNo"
                            label="电话号码"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personAge"
                            label="年龄"
                            width="180">
                        </el-table-column>
                        <el-table-column
                        fixed="right"
                        label="操作">
                        <template slot-scope="scope">
                            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
                        </template>
                        </el-table-column>
                        </el-table>
                    </div>
                     <div v-if="activeIndex=='2'">
                        <el-table
                        :data="patientlist2"
                        style="width: 60%">
                        <el-table-column
                            prop="consultId"
                            label="诊断id"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personName"
                            label="患者姓名"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personPhoneNo"
                            label="电话号码"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personAge"
                            label="年龄"
                            width="180">
                        </el-table-column>
                        <el-table-column
                        fixed="right"
                        label="操作">
                        <template slot-scope="scope">
                            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
                        </template>
                        </el-table-column>
                        </el-table>
                    </div>
                     <div v-if="activeIndex=='3'">
                        <el-table
                        :data="patientlist3"
                        style="width: 60%">
                        <el-table-column
                            prop="consultId"
                            label="诊断id"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personName"
                            label="患者姓名"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personPhoneNo"
                            label="电话号码"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="personAge"
                            label="年龄"
                            width="180">
                        </el-table-column>
                        <el-table-column
                        fixed="right"
                        label="操作">
                        <template slot-scope="scope">
                            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
                        </template>
                        </el-table-column>
                        </el-table>
                    </div>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script>
const axios = require('axios');
import navmenu from '../components/navmenu.vue'
export default {
    components:{
        navmenu
    },
    data(){
        return{
            activeIndex:"1",
            patientlist1:[
            ],
            patientlist2:[
            ],
            patientlist3:[
            ]
        }
    },
    methods:{
        changeto1(){
            this.activeIndex="1"
        },
        changeto2(){
            this.activeIndex="2"
        },
        changeto3(){
            this.activeIndex="3"
        },
        handleClick(row) {
            console.log(row)
            this.$router.push({ path: "/dispensing/"+ row.consultId});
        }
    },
    mounted:function(){
        console.log(this.GLOBAL.doctorinfo.doctorId)
        axios({
            method:"get",
            url:"http://121.196.150.130:8888/Demo/consult/findByDoc?id="+this.GLOBAL.doctorinfo.doctorId,
            }).then((res)=>{
                console.log(res.data);
                res.data.forEach(element => {
                    if(element.consultStatus=="待接诊"){
                        this.patientlist1.push(element)
                    }
                    else if(element.consultStatus=="进行中"){
                        this.patientlist2.push(element)
                    }
                    else if(element.consultStatus=="已完成"){
                        this.patientlist3.push(element)
                    }
                });
            })
    }
}
</script>

<style scoped>
</style>